package appinfo.util;

import java.util.List;

/**
 * 分页查询工具类
 */
public class PageBean<T> {
    /**每页显示的条数*/
    private Integer pageSize;
    /**当前页*/
    private Integer pageNo;
    /**总记录数*/
    private Integer totalCount;
    /**起始下标*/
    private Integer startIndex;
    /**总页数*/
    private Integer totalPage;
    /**
     *查询到的结果 T:代表泛型是任意类型 这个类型归当前类来约束
     *当此类的泛型是啥的时候那么返回的列表泛型必须是啥
     */
    private List<T> result;

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getStartIndex() {
        // 计算出起始下标  (当前页-1)*每页显示的条数
        startIndex = (pageNo-1)*pageSize;
        return startIndex;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    public Integer getTotalPage() {
        totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getResult() {
        return result;
    }

    public void setResult(List<T> result) {
        this.result = result;
    }
}
